package com.pubinfo.passbook.common.enums;

import com.pubinfo.passbook.common.exception.ServiceException;
import com.pubinfo.passbook.common.model.vo.base.BusinessErrorCode;
import lombok.Getter;

/**
 * 合同状态枚举
 */
@Getter
public enum ContractImportStatusEnum {
  CLAIMED(10, "已认领"),
  CLOSE(20, "作废"),
  ;
  
  private Integer status;
  
  private String desc;
  
  ContractImportStatusEnum(Integer status, String desc) {
    this.status = status;
    this.desc = desc;
  }
  
  public static ContractImportStatusEnum getEnum(Integer status) {
    for (ContractImportStatusEnum e : ContractImportStatusEnum.values()) {
      if (status.equals(e.getStatus())) {
        return e;
      }
    }
    throw new ServiceException(BusinessErrorCode.STATUS_NOT_EXIST);
  }
  
  public static Integer getStatusCodeByName(String status) {
    for (ContractImportStatusEnum e : ContractImportStatusEnum.values()) {
      if (status.equals(e.getDesc())) {
        return e.getStatus();
      }
    }
    throw new ServiceException(BusinessErrorCode.STATUS_NOT_EXIST);
  }
  //
  //public static List<String> getValues() {
  //  List<String> descs = new ArrayList<>();
  //  for (ContractImportStatusEnum e : values()) {
  //    if (e.getStatus() != ContractImportStatusEnum.ALL.getStatus()) {
  //
  //      descs.add(e.getDesc());
  //    }
  //  }
  //  return descs;
  //}
}
